import * as types from '../action-types';
import { push } from 'connected-react-router';
import { reg, login } from '../../api/session';
import { type } from 'os';

export default {
    reg(user) {
        return function (dispatch, getState) {
            reg(user).then(res => {
                if (res.code === 0) {
                    dispatch(push('/login'))
                }
            })
        }
    },
    login(user) {
        return function (dispatch, getState) {
            login(user).then(res => {
                if (res.code === 0) {
                    dispatch({type: types.LOGIN, playload: res.data})
                    dispatch(push('/profile'))
                }
            })
        }
    }
}